﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;

namespace Rowing
{
    class TimeChecker
    {
        private const int interval = 1;
        private DateTime lastTime;
        private int totalFrames = 0;
        private int lastFrames = 0;
        public int frameDiff
        {
            get;
            set;
        }

        public void Start()
        {
            lastTime = DateTime.Now;
            frameDiff = 0;
        }

        public bool Processing()
        {
            var cur = DateTime.Now;
            ++totalFrames;
            if (cur.Subtract(lastTime) > TimeSpan.FromSeconds(interval))
            {
                frameDiff = totalFrames - lastFrames;
                lastFrames = totalFrames;
                lastTime = cur;
                return true;
            }
            return false;
        }

        public void Stop()
        {

        }
    }
}
